package com.example.roomwordssample;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import java.util.List;

public class WordViewModel extends AndroidViewModel {
    private  WordRepository wordRepository;
    private LiveData<List<Word>> wordList;
    public WordViewModel( Application application) {
        super(application);
        wordRepository=new WordRepository(application);
        wordList=wordRepository.getAllWords();
    }
    public LiveData<List<Word>>getAllWords(){
        return wordList;
    }

    public void insert(Word word){
        wordRepository.insert(word);
    }
}
